﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BOMS.BLL
{
    /// <summary>
    /// 业务逻辑类M_UploadData 的摘要说明。
    /// </summary>
    public class M_UploadData
    {
        private readonly BOMS.DAL.M_UploadData dal = new BOMS.DAL.M_UploadData();
        public M_UploadData()
        { }
        #region  成员方法
       

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BOMS.Model.M_UploadData model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int ID)
        {

            dal.Delete(ID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BOMS.Model.M_UploadData GetModel(int ID)
        {

            return dal.GetModel(ID);
        }
        /// <summary>
        /// 更改记录状态，并记录Mome备注
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="Status"></param>
        /// <param name="OperateDescr"></param>
        public void UpdateFileStatus(int ID,int Status,string OperateDescr)
        {
            dal.UpdateFileStatus(ID, Status, OperateDescr);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得分页数据
        /// </summary>
        public List<BOMS.Model.M_UploadData>  GetListFromPage(string strWhere, string strOrderby, int pageSize, int curPage, out int recordCount)
        {
            DataSet ds = dal.GetListFromPage(strWhere, strOrderby, pageSize, curPage, out recordCount);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<BOMS.Model.M_UploadData> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<BOMS.Model.M_UploadData> DataTableToList(DataTable dt)
        {
            List<BOMS.Model.M_UploadData> modelList = new List<BOMS.Model.M_UploadData>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                BOMS.Model.M_UploadData model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new BOMS.Model.M_UploadData();                
                    dal.AssignModel(dt.Rows[n], model); 
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}
